package com.telit.common.listener;

import com.telit.common.event.SysOperationLogEvent;
import com.telit.common.entity.SysOperationLog;
import com.telit.common.service.LogService;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;


/**
 * 异步监听系统登录日志事件
 *
 * @author yuezhuang
 * @date 2022-09-19
 */
public class SysOperationLogEventLogListener {

    private final LogService logService;

    public SysOperationLogEventLogListener(LogService logService) {this.logService = logService;}

    @Async
    @Order
    @EventListener(SysOperationLogEvent.class)
    public void saveSysLog(SysOperationLogEvent event) {
        SysOperationLog sysOperationLog = (SysOperationLog) event.getSource();
        logService.saveLog(sysOperationLog);
    }

}
